<template>
  <div>
    <!--    <h1>当前求和为:{{this.$store.state.sum}}</h1>-->
    <h1>Person 人数和 {{personList.length}}</h1>
    <h1>当前求和为:{{sum}}</h1>
    <h1>当前求和*10为:{{bigSum}}</h1>
    <h1>nickname:{{nickname}}</h1>
    <h1>username:{{username}}</h1>
    <h1>age:{{age}}</h1>
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="increment(n)">+</button>
    <button @click="decrement(n)">-</button>
    <button @click="incrementOdd(n)">奇数再加</button>
    <button @click="incrementWait(n)">等待</button>
  </div>
</template>

<script>
import {mapState,mapGetters,mapActions,mapMutations} from 'vuex'
export default {
  name: "Count",
  data() {
    return {
      n:1,
      num: 0,
      user:{
        name:'lisi'
      }
    }
  },
  computed:{
    ...mapState('countAbout',['sum',"nickname","username","age"]),
    ...mapState('personAbout',{personList:"personList"}),
    ...mapGetters('countAbout',["bigSum"]), //常用
    // ...mapGetters({bigSum:"bigSum"}) //名称冲突时使用
  },
  methods:{
    // decrement(){
    //   this.$store.dispatch('jian',this.n)
    // },
    // increment(){
    //   this.$store.dispatch('jia',this.n)
    // },

    // incrementOdd(){
    //   this.$store.dispatch('jiaOdd',this.n)
    //
    // },
    // incrementWait(){
    //   this.$store.dispatch('jiaWait',this.n)
    // },
    ...mapActions('countAbout',{incrementOdd:'jiaOdd',incrementWait:'jiaWait'}),
    ...mapMutations('countAbout',{decrement:'JIAN',increment:'JIA'}),
  },
  created() {
    console.log(this)
  }
}
</script>

<style scoped>

</style>
